<?php namespace module\web;

use module\WfSite;
use system\model\PluginWebArticle;
use system\model\PluginWebCatgory;

class Site extends WfSite {

	//文章列表
	public function AdminIndex()
	{
		$data = Db::table( 'plugin_web_article' )->paginate( 10 );
		View::with( 'data', $data );
		$this->display('articles');
	}

	//发表文章
	public function AdminarticlePost()
	{
		if (IS_POST) {
			$model = new PluginWebArticle;
			$model->save($_POST);
			message( '保存成功', site_url( 'site/index' ), 'success' );
		}
		$cat = Db::table( 'plugin_web_catgory' )->get();
		View::with( 'cat', $cat );
		$this->display('article_post');
	}

	//栏目列表
	public function AdmincatLists()
	{
		$model = new PluginWebCatgory;
		$data = $model->dataTree();
		View::with( 'data', $data );
		$this->display('cat_lists');
	}

	//添加栏目
	public function admincatPost()
	{
		$model = new PluginWebCatgory;
		if (IS_POST) {
			$model->save($_POST);
			message( '保存成功', site_url( 'site/catLists' ), 'success' );
		}
		$cat = $model->dataTree();
		View::with( 'cat', $cat );
		$this->display( 'cat_post' );
	}

	//首页
	public function webHome() {
		$this->display( 'theme/default/index.html' );
	}
	//首页
	public function webShow() {
		$id =Request::get('id');
		$field = Db::table( 'plugin_web_article' )->find($id);
		View::with( 'field', $field );
		$this->display( 'theme/default/article.html' );
	}


}
